<template>
  <div class="bgf runBox">
    <div>
      <h4 style="margin:0 0 10px 0">流水记录 </h4>
      <el-row style="margin-bottom:10px">
        <el-col :span="24" >
          <div style="display:flex;align-items:center">
            <span>选择时间:</span>
           <el-date-picker v-model="value5" type="datetimerange" :picker-options="pickerOptions2" range-separator="至"
            start-placeholder="开始日期" end-placeholder="结束日期" align="right"> </el-date-picker>
           <el-input placeholder="请输入内容" v-model="input5" style="margin-left:20px;width:250px" class="input-with-select">
                  <el-button slot="append" @click="seachFun" icon="el-icon-search"></el-button>
            </el-input>
             <!-- <el-button type="primary" style="margin-left:20px" @click="seachFun">到处流水</el-button> -->
          </div>
        </el-col>
       
      </el-row>
      <div> </div>
      
      <el-table :data="tableData" border style="width: 100%" >
        <el-table-column prop="name" label="序号" width="60">
          <template slot-scope="scope">{{scope.$index+1}}</template>
        </el-table-column>
        <el-table-column prop="orderId" label="单号"> </el-table-column>   
        
        <el-table-column prop="createTime" label="支付时间">
          <template slot-scope="scope">{{timeFun(scope.row.createTime)}}</template>
        </el-table-column>     
        <el-table-column prop="userInfo.userPhone" label="用户手机"> </el-table-column>      
        <el-table-column prop="typeName" label="类别"> </el-table-column>   
        <el-table-column prop="amount" label="金额"> </el-table-column>   
        <el-table-column prop="channel" label="方式">
          <template slot-scope="scope">
            <span v-if="scope.row.channel == 'alipay'">支付宝</span>
            <span v-if="scope.row.channel == 'wxpay'">微信</span>
            <span v-if="scope.row.channel == 'huabei'">花呗</span>
          </template>
        </el-table-column>      
        <!-- <el-table-column prop="page_view" label="返点比例"> </el-table-column>       -->
        <el-table-column prop="amount" label="实际金额"> </el-table-column>      
        <el-table-column prop="amount" label="流向">
          <template slot-scope="scope">
            <div>
              <span v-if="scope.row.amount > 0 "> 入账</span>
              <span v-else-if="scope.row.amount < 0 "> 出账</span>
            </div>
          </template>  
        </el-table-column>      
        <el-table-column prop="balance" label="余额"> </el-table-column>      
      </el-table>
     
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
  import Http from '@/Http/Http'
  import getTime from '@/Http/getTime'

  export default {
    data() {
      var checkAge = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入关键字'));
        } else {
          callback();
        }
      };
      return {
        currentPage4: 1,//分野  
        total:0,      
        tableData: [],
        input5:'',
        page:1,
        pageSize:10,
        sheachValue:'',
         pickerOptions2: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        value5: ''
       
      }
    },
    created() {
      this.getlist()
    },
    methods: {
       getlist() {
        const parma = {
          "pageIndex":this.page,
          "pageSize":this.pageSize,
          "Integer":this.beginTime,
          "endTime":this.endTime
        };
        Http.getWaterList(parma)
        .then(res => {
          this.tableData = res.data.data.rows;
          this.total = res.data.data.total
          console.log(res)
        })
      },  

      timeFun(val) {
        return getTime(val)
      }, 
       //分页
      handleSizeChange(val) {
        this.pageSize = val;
        this.getlist()
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val;
        this.getlist()
        console.log(`当前页: ${val}`);
      },
     
      seachFun(){
        console.log(2332)
      }
    }
  }
</script>
<style>
.runBox{
  background: #fff;
  padding:10px;
  min-height: 500px
}
</style>

